import pandas as pd
from scipy.stats import pearsonr

# 创建示例数据
data = {
    'Sales': [350, 400, 450, 500, 550],
    'Advertising': [20, 30, 40, 50, 60],
    'Profit': [100, 150, 200, 250, 300]
}

# 将数据转换为DataFrame格式
df = pd.DataFrame(data)

# 计算Sales与Advertising的皮尔逊相关系数和p-value
sales_ad_corr, sales_ad_pvalue = pearsonr(df['Sales'], df['Advertising'])
print("Sales与Advertising的皮尔逊相关系数:", sales_ad_corr)
print("Sales与Advertising的p-value:", sales_ad_pvalue)

# 计算Sales与Profit的皮尔逊相关系数和p-value
sales_profit_corr, sales_profit_pvalue = pearsonr(df['Sales'], df['Profit'])
print("Sales与Profit的皮尔逊相关系数:", sales_profit_corr)
print("Sales与Profit的p-value:", sales_profit_pvalue)
